{"data":{"kind":"file","path":"README.md","version_id":"e8ym5skdw7kw552nk3lljcqy","entry":{"name":"README.md","path":"README.md","is_directory":false,"size":3207,"modified_at":"2026-02-11T18:53:55.265000","content_hash":"e9192c6c21dd11aa12968cfdeca310afe1cb13ee75fb3ebb047387d01bea9960"},"entries":[],"content":"# Trading Strategy RL Environment\n\nPrime Intellect Lab environment for training trading strategies via reinforcement learning.\n\n## 🎯 Purpose\n\nTrain AI agents to:\n1. Analyze market conditions (price, RSI, momentum, Bollinger Bands)\n2. Generate optimal trading signals (LONG, SHORT, CLOSE)\n3. Optimize parameters (TP, SL, position sizing)\n4. Maximize risk-adjusted returns (Sharpe ratio)\n\n## 📊 Dataset\n\n**Source:** Mock market data (replace with real Bankr/Avantis history)\n\nContains market states with:\n- Price and volume\n- Technical indicators: RSI, Momentum, Bollinger Bands\n- Trend classification (bullish/bearish/neutral)\n\n## 🧪 Evaluation Rubric\n\n**Scoring Criteria:**\n1. **Total PnL (40%)** - Cumulative profit/loss percentage\n2. **Sharpe Ratio (30%)** - Risk-adjusted return (mean / std)\n3. **Drawdown Penalty (30%)** - Maximum drawdown penalty\n\n**Score Range:** 0.0 - 1.0\n\n**Formula:**\n```\nScore = (PnL Score × 0.4) + (Sharpe Score × 0.3) + (Drawdown Score × 0.3)\n```\n\n## 🚀 Usage\n\n### Install\n```bash\ncd ~/clawd/environments/trading-strategy-rl\npip install -e .\n```\n\n### Test Environment\n```bash\npython environment.py\n```\n\n### Production Integration\n\n**Connect to Bankr API:**\n```python\n# In environment.py, replace mock generation with:\nimport bankr\n\n# Real execution\nresult = bankr.execute_trade(\n    symbol=\"BTC-PERP\",\n    action=\"LONG\",\n    size=0.01,\n    tp=entry_price * 1.03,\n    sl=entry_price * 0.97\n)\n```\n\n**Connect to Avantis Direct:**\n```python\n# Use Avantis smart contracts via Ethers.js\nimport { Contract } from 'ethers';\nimport AvantisABI from './Avantis.json';\n\nconst avantis = new Contract(AVANTIS_ADDRESS, AvantisABI, signer);\nawait avantis.openPosition({ ... });\n```\n\n### Use with Prime Lab\n\nFor full RL training with `prime-rl`:\n```bash\n# Setup workspace\nprime lab setup trading-strategy-rl\n\n# Train\nprime train --env trading-strategy-rl --model <your-model>\n\n# Evaluate\nprime eval --env trading-strategy-rl --model <your-model>\n```\n\n## 📁 Dataset Format\n\n```json\n{\n  \"input\": {\n    \"price\": 100.50,\n    \"volume\": 5000,\n    \"rsi\": 25.3,\n    \"momentum\": 12.5,\n    \"bb_upper\": 105.0,\n    \"bb_lower\": 95.0,\n    \"trend\": \"bullish\"\n  },\n  \"expected_output\": {\n    \"action\": \"LONG\",\n    \"confidence\": 0.85\n  }\n}\n```\n\n## 🤖 Agent Output Format\n\n```json\n{\n  \"action\": \"LONG\",\n  \"confidence\": 0.85,\n  \"take_profit\": 1.03,\n  \"stop_loss\": 0.97,\n  \"position_size\": 0.01,\n  \"reasoning\": \"RSI oversold (<30) + strong bullish momentum (>10)\"\n}\n```\n\n## 📈 Current Strategy (Baseline)\n\n**Rules-based (to be replaced by RL):**\n- **LONG**: RSI < 30 + Momentum > 15%\n- **SHORT**: RSI > 70 + Momentum < -15%\n- **TP**: 3%\n- **SL**: 3% trailing\n- **Position**: 10% of portfolio per trade\n\n## 🔮 Future Enhancements\n\n1. **Real Data Integration** - Connect to Bankr/Avantis history\n2. **Multi-Asset Trading** - BTC, ETH, SOL, MOLGE\n3. **Portfolio Optimization** - Dynamic position sizing based on correlation\n4. **Market Regime Detection** - Adapt strategy to volatility/trend\n5. **Live Paper Trading** - Simulate in real-time before going live\n\n## 🤝 Contributing\n\nNew strategies are evaluated and backtested before deployment.\n\n---\n\n*Part of Bernard's trading automation system*\n","encoding":"utf-8","truncated":false,"total_bytes":3207},"status":null}